home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dev / insight_dev.idb / usr / share / Insight / bin / valid_helpmaps.z / valid_helpmaps
Encoding:
Text File  |  2002-10-16  |  2.4 KB  |  102 lines

  1. #!/usr/bin/perl
  2. #
  3. # Copyright 2002, Silicon Graphics, Inc.
  4. # All Rights Reserved.
  5. #
  6. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  7. # the contents of this file may not be disclosed to third parties, copied or
  8. # duplicated in any form, in whole or in part, without the prior written
  9. # permission of Silicon Graphics, Inc.
  10. #
  11. # RESTRICTED RIGHTS LEGEND:
  12. # Use, duplication or disclosure by the Government is subject to restrictions
  13. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  14. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  15. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  16. # rights reserved under the Copyright Laws of the United States.
  17. #
  18. # --------------
  19. # valid_helpmaps
  20. # --------------
  21. # syntax:
  22. #
  23. #    valid_helpmaps <sgml_file> <helpmap_dir>
  24. #
  25.  
  26. $SGML = $ARGV[0];
  27. $DIR  = $ARGV[1];
  28. if ($SGML eq '' || $DIR eq '') {
  29.     &usage("SGML file (${SGML}) or helpmap directory (${DIR}) not specified");
  30. }
  31.  
  32. if (!(-f $SGML) || !(-d $DIR)) {
  33.     &usage("SGML file (${SGML}) or helpmap directory (${DIR}) not found");
  34. }
  35.  
  36.  
  37. $VALID_HELPMAPS = '';
  38.  
  39. my(@hm, @hl, @pts) = ();
  40. my($bAdd) = 0;
  41.  
  42. @hm = split(/\n/, `(find ${DIR} -type f -print)`);
  43.  
  44. foreach $f (@hm) {
  45.  
  46.     $bAdd = 0;
  47.  
  48.     open(HELPMAP, "${f}") || &usage("Cannot open helpmap: ${f}");
  49.     @hl = <HELPMAP>;
  50.     close(HELPMAP);
  51.  
  52.     # check helpmap points, compare to sgml file(s)
  53.     #
  54.     foreach $s (@hl) {
  55.  
  56.       if ($s !~ /\;/) {
  57.           next;
  58.       }
  59.  
  60.       @pts = split(/\;/, $s);
  61.  
  62.       # we go until we find a valid point and then get out.
  63.       # at some point, we can (and probably should) do more here...
  64.       # 
  65.       if ($pts[1] =~ /^HREF/i || $pts[4] =~ /\.htm/ || $pts[4] =~ /^\#/) {
  66.           $bAdd = 1;
  67.       } else {
  68.  
  69.           $cmd = "egrep \"(HELPID\|helpid) \?= \?\\\"" . 
  70.                  $pts[4] . "\\\"\" ${SGML}";
  71.  
  72.           open(CMD, "$cmd |") || &usage("Cannot start command: ${cmd}");
  73.           while (<CMD>) {
  74.             chop;
  75.             if ($_ ne '') {
  76.                 $bAdd = 1;
  77.                 last;
  78.             }
  79.           }
  80.           close(CMD);
  81.       }
  82.  
  83.       if ($bAdd) {
  84.           $VALID_HELPMAPS .= "${f} ";
  85.           last;
  86.       }
  87.     }
  88. }
  89.  
  90. print "${VALID_HELPMAPS}\n";
  91. exit 0;
  92.  
  93.  
  94. sub usage {
  95.  
  96.     my($err) = @_;
  97.     print "\nusage:  valid_helpmaps <sgml_file> <helpmap_dir>\n",
  98.           ($err ne '' ? "${err}\n" : '');
  99.     exit(-1);
  100. }
  101.  
  102.